package com.hxkcloud.nurse.activitys;

import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hxkcloud.nurse.R;

/**
 * Created by william_sun on 2016-07-06.
 * Description:注册角色选择
 */
public class RoleSelectActivity extends BaseActivity implements View.OnClickListener {

    private LinearLayout ll_whole;
    private LinearLayout ll_user;
    private ImageView iv_user;
    private ImageView iv_user1;
    private TextView tv_user;
    private LinearLayout ll_nurse;
    private ImageView iv_nurse;
    private ImageView iv_nurse1;
    private TextView tv_nurse;
    private Button bt_sure;

    private int userOrNurse = 0;//0user 1nurse

    private String tel = "";//注册手机
    private String password = "";//注册密码

    @Override
    protected void updateByHandler(Message msg) {
        switch (msg.what) {

        }
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_roleselect);
        if (getIntent().hasExtra("tel")) {
            tel = getIntent().getStringExtra("tel");
        }
        if (getIntent().hasExtra("password")) {
            password = getIntent().getStringExtra("password");
        }
        initView();
    }

    @Override
    protected void initView() {
        ll_whole = (LinearLayout) findViewById(R.id.ll_roleselect);
        ll_user = (LinearLayout) findViewById(R.id.ll_roleselect_user);
        iv_user = (ImageView) findViewById(R.id.iv_roleselect_user);
        iv_user1 = (ImageView) findViewById(R.id.iv_roleselect_user1);
        tv_user = (TextView) findViewById(R.id.tv_roleselect_user);
        ll_nurse = (LinearLayout) findViewById(R.id.ll_roleselect_nurse);
        iv_nurse = (ImageView) findViewById(R.id.iv_roleselect_nurse);
        iv_nurse1 = (ImageView) findViewById(R.id.iv_roleselect_nurse1);
        tv_nurse = (TextView) findViewById(R.id.tv_roleselect_nurse);
        bt_sure = (Button) findViewById(R.id.bt_roleselect_sure);

        setTitlePadding(ll_whole);
        LinearLayout.LayoutParams lp_head = new LinearLayout.LayoutParams(screenWidth * 2 / 5, screenWidth * 2 / 5);
        iv_user.setLayoutParams(lp_head);
        iv_nurse.setLayoutParams(lp_head);
        LinearLayout.LayoutParams lp_check = new LinearLayout.LayoutParams(screenWidth / 12, screenWidth / 12);
        iv_user1.setLayoutParams(lp_check);
        iv_nurse1.setLayoutParams(lp_check);


        ll_user.setOnClickListener(this);
        ll_nurse.setOnClickListener(this);
        bt_sure.setOnClickListener(this);
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_roleselect_user:
                userOrNurse = 0;
                iv_user1.setImageResource(R.drawable.register_btn);
                tv_user.setTextColor(ContextCompat.getColor(mContext, R.color.black_text));
                iv_nurse1.setImageResource(R.drawable.register_btn_n);
                tv_nurse.setTextColor(ContextCompat.getColor(mContext, R.color.grey_text2));
                break;
            case R.id.ll_roleselect_nurse:
                userOrNurse = 1;
                iv_user1.setImageResource(R.drawable.register_btn_n);
                tv_user.setTextColor(ContextCompat.getColor(mContext, R.color.grey_text2));
                iv_nurse1.setImageResource(R.drawable.register_btn);
                tv_nurse.setTextColor(ContextCompat.getColor(mContext, R.color.black_text));
                break;
            case R.id.bt_roleselect_sure:
                if (userOrNurse == 0) {
                    Intent iUser = new Intent(mContext, UserBasicInfoActivity.class);
                    iUser.putExtra("tel", tel);
                    iUser.putExtra("password", password);
                    startActivity(iUser);
                } else {
                    Intent iNurse = new Intent(mContext, PersonalInfoForDNActivity.class);
                    iNurse.putExtra("tel", tel);
                    iNurse.putExtra("password", password);
                    startActivity(iNurse);
                }
                break;
        }
    }
}
